package com.lds.config.center.server.business.itemchange.controller;

import com.lds.config.center.common.model.itemchange.request.ItemChangeBaseBatchCreateRequest;
import com.lds.config.center.common.model.itemchange.request.ItemChangeBaseBatchDeleteRequest;
import com.lds.config.center.common.model.itemchange.request.ItemChangeBaseBatchUpdateRequest;
import com.lds.config.center.common.model.itemchange.request.ItemChangeBaseCreateRequest;
import com.lds.config.center.common.model.itemchange.request.ItemChangeBaseDeleteRequest;
import com.lds.config.center.common.model.itemchange.request.ItemChangeBaseGetByIdRequest;
import com.lds.config.center.common.model.itemchange.request.ItemChangeBaseGetByIdsRequest;
import com.lds.config.center.common.model.itemchange.request.ItemChangeBaseGetByKeyRequest;
import com.lds.config.center.common.model.itemchange.request.ItemChangeBaseListPageRequest;
import com.lds.config.center.common.model.itemchange.request.ItemChangeBaseListRequest;
import com.lds.config.center.common.model.itemchange.request.ItemChangeBaseUpdateRequest;
import com.lds.config.center.common.model.itemchange.response.ItemChangeBaseBatchCreateResponse;
import com.lds.config.center.common.model.itemchange.response.ItemChangeBaseBatchDeleteResponse;
import com.lds.config.center.common.model.itemchange.response.ItemChangeBaseBatchUpdateResponse;
import com.lds.config.center.common.model.itemchange.response.ItemChangeBaseDeleteResponse;
import com.lds.config.center.common.model.itemchange.response.ItemChangeBaseListResponse;
import com.lds.config.center.common.model.itemchange.response.ItemChangeBaseResponse;
import com.lds.config.center.server.business.itemchange.service.ItemChangeBaseService;
import com.lds.management.center.common.model.db.OrderBy;
import com.lds.management.center.common.model.db.PageResult;
import com.lds.management.center.common.model.dto.ResultDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 基础前端控制器
 *
 * @author lidongsheng
 * @since 2025-06-30
 */
@Slf4j
@RestController
@RequestMapping("/api/common/item-change")
public class ItemChangeBaseController {

    @Autowired
    private ItemChangeBaseService itemChangeBaseService;

    /**
     * 创建
     */
    @PostMapping("/create")
    public ResultDTO<ItemChangeBaseResponse> createItemChange(@RequestBody @Validated ItemChangeBaseCreateRequest request) {
        return itemChangeBaseService.createItemChange(request);
    }

    /**
     * 批量创建
     */
    @PostMapping("/batch-create")
    ResultDTO<ItemChangeBaseBatchCreateResponse> batchCreateItemChange(@RequestBody @Validated ItemChangeBaseBatchCreateRequest request) {
        return itemChangeBaseService.batchCreateItemChange(request);
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    ResultDTO<ItemChangeBaseDeleteResponse> deleteItemChange(@RequestBody ItemChangeBaseDeleteRequest request) {
        return itemChangeBaseService.deleteItemChange(request);
    }

    /**
     * 批量删除
     */
    @PostMapping("/batch-delete")
    ResultDTO<ItemChangeBaseBatchDeleteResponse> batchDeleteItemChange(@RequestBody @Validated ItemChangeBaseBatchDeleteRequest request) {
        return itemChangeBaseService.batchDeleteItemChange(request);
    }

    /**
     * 更新
     */
    @PostMapping("/update")
    ResultDTO<ItemChangeBaseResponse> updateItemChange(@RequestBody @Validated ItemChangeBaseUpdateRequest request) {
        return itemChangeBaseService.updateItemChange(request);
    }

    /**
     * 批量更新
     */
    @PostMapping("/batch-update")
    ResultDTO<ItemChangeBaseBatchUpdateResponse> batchUpdateItemChange(@RequestBody @Validated ItemChangeBaseBatchUpdateRequest request) {
        return itemChangeBaseService.batchUpdateItemChange(request);
    }

    /**
     * 查询
     */
    @PostMapping("/list")
    ResultDTO<ItemChangeBaseListResponse> listItemChange(@RequestBody ItemChangeBaseListRequest request) {
        return itemChangeBaseService.listItemChange(request);
    }

    /**
     * 查询所有
     */
    @PostMapping("/list-all")
    ResultDTO<ItemChangeBaseListResponse> listAllItemChange(@RequestBody OrderBy orderBy) {
        return itemChangeBaseService.listAllItemChange(orderBy);
    }

    /**
     * 根据ID查询
     */
    @PostMapping("/get")
    ResultDTO<ItemChangeBaseResponse> getItemChangeById(@RequestBody @Validated ItemChangeBaseGetByIdRequest request) {
        return itemChangeBaseService.getItemChangeById(request);
    }

    /**
     * 根据ID集合查询
     */
    @PostMapping("/gets")
    ResultDTO<ItemChangeBaseListResponse> getItemChangeByIds(@RequestBody @Validated ItemChangeBaseGetByIdsRequest request) {
        return itemChangeBaseService.getItemChangeByIds(request);
    }

    /**
     * 分页查询
     */
    @PostMapping("/list-page")
    ResultDTO<PageResult<ItemChangeBaseResponse>> listItemChangePage(@RequestBody ItemChangeBaseListPageRequest request) {
        return itemChangeBaseService.listItemChangePage(request);
    }

    /**
     * 业务主键对应数据是否存在
     */
    @PostMapping("/isExist")
    public ResultDTO<Boolean> isExist(@RequestBody @Validated ItemChangeBaseGetByKeyRequest request) {
        return ResultDTO.success(itemChangeBaseService.getItemChangeByKey(request) != null);
    }

    /**
     * 异步批量创建 - 慎用(并发不高可以无脑使用)
     */
    @PostMapping("/batch-create-async")
    ResultDTO<ItemChangeBaseBatchCreateResponse> batchCreateItemChangeAsync(@RequestBody @Validated ItemChangeBaseBatchCreateRequest request) {
        return itemChangeBaseService.batchCreateItemChangeAsync(request);
    }

    /**
     * 异步批量删除 - 慎用(并发不高可以无脑使用)
     */
    @PostMapping("/batch-delete-async")
    ResultDTO<ItemChangeBaseBatchDeleteResponse> batchDeleteItemChangeAsync(@RequestBody @Validated ItemChangeBaseBatchDeleteRequest request) {
        return itemChangeBaseService.batchDeleteItemChangeAsync(request);
    }

    /**
     * 异步批量更新 - 慎用(并发不高可以无脑使用)
     */
    @PostMapping("/batch-update-async")
    ResultDTO<ItemChangeBaseBatchUpdateResponse> batchUpdateItemChangeAsync(@RequestBody @Validated ItemChangeBaseBatchUpdateRequest request) {
        return itemChangeBaseService.batchUpdateItemChangeAsync(request);
    }

}